package com.ssy.lingxi.order.entity;

import com.ssy.lingxi.order.handler.converter.JpaJsonToPayNodeConverter;
import com.ssy.lingxi.order.model.bo.PayNodeBO;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 基础交易流程（系统初始化进行配置）
 *
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-23
 */
@Entity
@Table(schema = "public", name = "ord_base_trade_process", indexes = {@Index(name = "ord_base_trade_process_type_idx", columnList = "processType"), @Index(name = "ord_base_trade_process_status_idx", columnList = "status")})
public class BaseTradeProcessDO implements Serializable {
    private static final long serialVersionUID = 509660445577071473L;

    /**
     * 主键Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ord_base_trade_process_seq")
    @SequenceGenerator(sequenceName = "ord_base_trade_process_seq", name = "ord_base_trade_process_seq", allocationSize = 1)
    private Long id;

    /**
     * 流程枚举值，定义在 BaseTradeProcessEnum 中
     */
    @Column
    private Integer code;

    /**
     * 流程对应的工作流的Key
     */
    @Column(columnDefinition = "varchar(100)")
    private String processKey;

    /**
     * 流程名称
     */
    @Column(columnDefinition = "varchar(50)")
    private String name;

    /**
     * 流程类型，定义在 OrderTradeProcessTypeEnum 中
     */
    @Column
    private Integer processType;

    /**
     * 流程中需要支付环节的次数
     */
    @Column
    private Integer payTimes;

    /**
     * 流程类型，定义在 WorkflowProcessKindEnum 中， 1-内部流程，2-外部流程，3-复杂流程
     */
    @Column
    private Integer processKind;

    /**
     * 启动后是否需要执行第一个步骤，即调用工作流提供的startProcessAndExecFirstStep接口
     */
    @Column
    private Boolean skipFirstStep;

    /**
     * 支付环节配置
     */
    @Convert(converter = JpaJsonToPayNodeConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<PayNodeBO> payNodes;

    /**
     * 状态，0-停用，1-启用
     */
    @Column
    private Integer status;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getProcessKey() {
        return processKey;
    }

    public void setProcessKey(String processKey) {
        this.processKey = processKey;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getProcessType() {
        return processType;
    }

    public void setProcessType(Integer processType) {
        this.processType = processType;
    }

    public Integer getPayTimes() {
        return payTimes;
    }

    public void setPayTimes(Integer payTimes) {
        this.payTimes = payTimes;
    }

    public Integer getProcessKind() {
        return processKind;
    }

    public void setProcessKind(Integer processKind) {
        this.processKind = processKind;
    }

    public Boolean getSkipFirstStep() {
        return skipFirstStep;
    }

    public void setSkipFirstStep(Boolean skipFirstStep) {
        this.skipFirstStep = skipFirstStep;
    }

    public List<PayNodeBO> getPayNodes() {
        return payNodes;
    }

    public void setPayNodes(List<PayNodeBO> payNodes) {
        this.payNodes = payNodes;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }
}
